package com.hh.bss.report.controller;

import static com.hh.bss.util.extjs.JsonHelper.outJson;

import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.springframework.stereotype.Controller;

import com.hh.bss.auth.client.OnlineManager;
import com.hh.bss.auth.client.OnlineUser;
import com.hh.bss.base.BaseSpringController;
import com.hh.bss.common.ConstantDic;
import com.hh.bss.common.page.Page;
import com.hh.bss.common.page.PageRequest;
import com.hh.bss.report.service.AccountReportService;
import com.hh.bss.report.vo.query.ReportQuery;
import com.hh.bss.sysadmin.entity.SystemAuditLog;
import com.hh.bss.sysadmin.vo.query.SystemAuditLogQuery;
import com.hh.bss.util.ExcelHelper;
import com.hh.bss.util.extjs.ExtJsPageHelper;
import com.hh.bss.util.extjs.ListRange;

@Controller
public class ReportController extends BaseSpringController {
	protected static final String DEFAULT_SORT_COLUMNS = null; 
	private AccountReportService accountReportService;
	private static final String CONTENT_EXCEL_TYPE = "application/vnd.ms-excel";
	public void setAccountReportServiceImpl(AccountReportService accountReportService){
		this.accountReportService=accountReportService;
	}
	//员工业绩报表
	public void yjlist(HttpServletRequest request,HttpServletResponse response,ReportQuery reportQuery) throws IOException
	{
		//
		PageRequest<Map> pr = ExtJsPageHelper.createPageRequestForExtJs(request, DEFAULT_SORT_COLUMNS);
		OnlineManager onlineManager=super.getOnlineManager(request, response);
		if (onlineManager!=null){
			OnlineUser onlineUser=onlineManager.getOnlineUser();
			if (onlineUser!=null)reportQuery.setOnlineUser(onlineUser);
			
		}
		//Page page = accountReportService.workKpi(reportQuery);
		
		List list=accountReportService.accountYJSum(reportQuery);
		
		//List<SystemAuditLog> SystemAuditLoglist = (List) page.getResult();
		ListRange<SystemAuditLog> resultList = new ListRange<SystemAuditLog>();
		resultList.setRows(list);
		//resultList.setTotalSize(page.getTotalCount());
		resultList.setMessage("ok");
		resultList.setSuccess(true);
		outJson(response,resultList);
	}
	//个人业绩总结
	public void myyjlist(HttpServletRequest request,HttpServletResponse response,ReportQuery reportQuery) throws IOException
	{
		//
		PageRequest<Map> pr = ExtJsPageHelper.createPageRequestForExtJs(request, DEFAULT_SORT_COLUMNS);
		OnlineManager onlineManager=super.getOnlineManager(request, response);
		if (onlineManager!=null){
			OnlineUser onlineUser=onlineManager.getOnlineUser();
			if (onlineUser!=null)reportQuery.setOnlineUser(onlineUser);
			//if (onlineUser!=null)reportQuery.setAccount(onlineUser.getUsername());
			
		}
		//Page page = accountReportService.workKpi(reportQuery);
		
		//List list=accountReportService.myYJ(reportQuery);
		List list=accountReportService.bothYJ(reportQuery);
		
		//List<SystemAuditLog> SystemAuditLoglist = (List) page.getResult();
		ListRange<SystemAuditLog> resultList = new ListRange<SystemAuditLog>();
		resultList.setRows(list);
		resultList.setTotal(list.size()-1);
		resultList.setMessage("ok");
		resultList.setSuccess(true);
		outJson(response,resultList);
	}
	public void myyjlistdown(HttpServletRequest request,HttpServletResponse response,ReportQuery reportQuery) throws IOException
	{
		//
		PageRequest<Map> pr = ExtJsPageHelper.createPageRequestForExtJs(request, DEFAULT_SORT_COLUMNS);
		OnlineManager onlineManager=super.getOnlineManager(request, response);
		if (onlineManager!=null){
			OnlineUser onlineUser=onlineManager.getOnlineUser();
			if (onlineUser!=null)reportQuery.setOnlineUser(onlineUser);
			//if (onlineUser!=null)reportQuery.setAccount(onlineUser.getUsername());
			
		}
		//Page page = accountReportService.workKpi(reportQuery);
		
		List list=accountReportService.myYJ(reportQuery);
		
		try{
       		String title=new String(("业绩检测.xls").getBytes("GBK"),"iso8859-1"); 
       		//HttpServletResponse response=ServletActionContext.getResponse();
       		response.setHeader("Content-Disposition", "attachment;filename=\""+title+"\"");
       		response.setContentType(CONTENT_EXCEL_TYPE);
       		ServletOutputStream os = response.getOutputStream();
       		Map titles=new LinkedHashMap();
       		//姓名	BD call	BD call完成	客户拜访	客户拜访完成	面试候选人	面试候选人完成	推荐候选人给客户	推荐候选人给客户完成	有效简历输入	有效简历输入完成	KPI 总分数
       		//'account','name','bdCallCount','bdCallCountFin','customerVisitCount','customerVisitCountFin','giCount','giCountFin','recomCount','recomCountFin','cvCount','cvCountFin'

       		titles.put("name", "员工");
       		titles.put("custName", "客户简称");
       		
       		titles.put("jobName", "职位名称");
       		titles.put("cvName", "人选姓名");
       		titles.put("deptName", "部门");
       		titles.put("yj", "服务费金额");
       		titles.put("yjrate", "所占业绩金额");
       		
       		
       		titles.put("applyD", "收到OFFER日期");
       		titles.put("sendDt", "发账单日期");
       		
       		titles.put("confirmDt", "到款日期");
       		
       		HSSFWorkbook wb = ExcelHelper.createExcelWorkbook("业绩检测", list, titles);
       		wb.write(os);
       		os.flush();
       		os.close();  
       	}catch(Exception ex){
       		 ex.printStackTrace();
       	}
	}
	public void myofferyjlist(HttpServletRequest request,HttpServletResponse response,ReportQuery reportQuery) throws IOException
	{
		//
		PageRequest<Map> pr = ExtJsPageHelper.createPageRequestForExtJs(request, DEFAULT_SORT_COLUMNS);
		OnlineManager onlineManager=super.getOnlineManager(request, response);
		if (onlineManager!=null){
			OnlineUser onlineUser=onlineManager.getOnlineUser();
			if (onlineUser!=null)reportQuery.setOnlineUser(onlineUser);
			//if (onlineUser!=null)reportQuery.setAccount(onlineUser.getUsername());
			
		}
		//Page page = accountReportService.workKpi(reportQuery);
		
		List list=accountReportService.myOfferYJ(reportQuery);
		
		//List<SystemAuditLog> SystemAuditLoglist = (List) page.getResult();
		ListRange<SystemAuditLog> resultList = new ListRange<SystemAuditLog>();
		resultList.setRows(list);
		resultList.setTotal(list.size()-1);
		resultList.setMessage("ok");
		resultList.setSuccess(true);
		outJson(response,resultList);
	}
	public void myofferyjlistdown(HttpServletRequest request,HttpServletResponse response,ReportQuery reportQuery) throws IOException
	{
		//
		PageRequest<Map> pr = ExtJsPageHelper.createPageRequestForExtJs(request, DEFAULT_SORT_COLUMNS);
		OnlineManager onlineManager=super.getOnlineManager(request, response);
		if (onlineManager!=null){
			OnlineUser onlineUser=onlineManager.getOnlineUser();
			if (onlineUser!=null)reportQuery.setOnlineUser(onlineUser);
			//if (onlineUser!=null)reportQuery.setAccount(onlineUser.getUsername());
			
		}
		//Page page = accountReportService.workKpi(reportQuery);
		
		List list=accountReportService.myOfferYJ(reportQuery);
		
		try{
       		String title=new String(("Offer监测.xls").getBytes("GBK"),"iso8859-1"); 
       		//HttpServletResponse response=ServletActionContext.getResponse();
       		response.setHeader("Content-Disposition", "attachment;filename=\""+title+"\"");
       		response.setContentType(CONTENT_EXCEL_TYPE);
       		ServletOutputStream os = response.getOutputStream();
       		Map titles=new LinkedHashMap();
       		//姓名	BD call	BD call完成	客户拜访	客户拜访完成	面试候选人	面试候选人完成	推荐候选人给客户	推荐候选人给客户完成	有效简历输入	有效简历输入完成	KPI 总分数
       		//'account','name','bdCallCount','bdCallCountFin','customerVisitCount','customerVisitCountFin','giCount','giCountFin','recomCount','recomCountFin','cvCount','cvCountFin'

       		titles.put("name", "员工");
       		titles.put("custName", "客户简称");
       		
       		titles.put("jobName", "职位名称");
       		titles.put("cvName", "人选姓名");
       		titles.put("deptName", "部门");
       		titles.put("yj", "服务费金额");
       		titles.put("yjrate", "所占业绩金额");
       		
       		
       		titles.put("applyD", "收到OFFER日期");
       		//titles.put("sendDt", "发账单日期");
       		
       		//titles.put("confirmDt", "到款日期");
       		
       		HSSFWorkbook wb = ExcelHelper.createExcelWorkbook("Offer监测", list, titles);
       		wb.write(os);
       		os.flush();
       		os.close();  
       	}catch(Exception ex){
       		 ex.printStackTrace();
       	}
	}
	public void kpilist(HttpServletRequest request,HttpServletResponse response,ReportQuery reportQuery) throws IOException
	{
		//
		PageRequest<Map> pr = ExtJsPageHelper.createPageRequestForExtJs(request, DEFAULT_SORT_COLUMNS);
		OnlineManager onlineManager=super.getOnlineManager(request, response);
		if (onlineManager!=null){
			OnlineUser onlineUser=onlineManager.getOnlineUser();
			if (onlineUser!=null)reportQuery.setOnlineUser(onlineUser);
			
		}
		//Page page = accountReportService.workKpi(reportQuery);
		
		List list=accountReportService.workKpi(reportQuery);
		
		//List<SystemAuditLog> SystemAuditLoglist = (List) page.getResult();
		ListRange<SystemAuditLog> resultList = new ListRange<SystemAuditLog>();
		resultList.setRows(list);
		//resultList.setTotalSize(page.getTotalCount());
		resultList.setMessage("ok");
		resultList.setSuccess(true);
		outJson(response,resultList);
	}
	public void kpidown(HttpServletRequest request,HttpServletResponse response,ReportQuery reportQuery) throws IOException
	{
		PageRequest<Map> pr = ExtJsPageHelper.createPageRequestForExtJs(request, DEFAULT_SORT_COLUMNS);
		OnlineManager onlineManager=super.getOnlineManager(request, response);
		if (onlineManager!=null){
			OnlineUser onlineUser=onlineManager.getOnlineUser();
			if (onlineUser!=null)reportQuery.setOnlineUser(onlineUser);
			
		}
		//Page page = accountReportService.workKpi(reportQuery);
		
		List list=accountReportService.workKpi(reportQuery);
		//
		try{
       		String title=new String(("员工KPI报表.xls").getBytes("GBK"),"iso8859-1"); 
       		//HttpServletResponse response=ServletActionContext.getResponse();
       		response.setHeader("Content-Disposition", "attachment;filename=\""+title+"\"");
       		response.setContentType(CONTENT_EXCEL_TYPE);
       		ServletOutputStream os = response.getOutputStream();
       		Map titles=new LinkedHashMap();
       		//姓名	BD call	BD call完成	客户拜访	客户拜访完成	面试候选人	面试候选人完成	推荐候选人给客户	推荐候选人给客户完成	有效简历输入	有效简历输入完成	KPI 总分数
       		//'account','name','bdCallCount','bdCallCountFin','customerVisitCount','customerVisitCountFin','giCount','giCountFin','recomCount','recomCountFin','cvCount','cvCountFin'
       		titles.put("name", "姓名");
       		titles.put("deptName", "部门");
       		//ConstantDic.getConstantDicCategoryValue(ConstantDic.UserStatus, stau);
       		titles.put("statusName", "状态");
       		//titles.put("bdCallCount", "BD call");
       		
       		titles.put("cvBaseCount", "人选基本信息+简历指标");
       		titles.put("cvBaseCountFin", "人选基本信息");
       		titles.put("cvBaseCountRate", "人选基本信息完成率");
       		
       		titles.put("cvCount", "人选简历指标");
       		titles.put("cvCountFin", "人选简历");
       		titles.put("cvCountRate", "人选简历完成率");
       		
       		titles.put("bdCallCount", "BD CALL指标");
       		titles.put("bdCallCountFin", "BD CALL");
       		titles.put("bdCallCountFinRate", "BD CALL完成率");
       		
       	    //titles.put("customerVisitCount", "客户拜访");
       		titles.put("customerVisitCount", "VISIT指标");
       		titles.put("customerVisitCountFin", "VISIT");
       		titles.put("customerVisitCountFinRate", "VISIT完成率");
       		
       		titles.put("cvDayCount", "联系人选数量指标");
       		titles.put("cvDayCountFin", "联系人选数量");
       		titles.put("cvDayCountFinRate", "联系人选数量完成率");
       		
       		titles.put("recomCountIn", "内部推荐指标");
       		titles.put("recomCountInFin", "内部推荐");
       		titles.put("recomCountInFinRate", "内部推荐完成率");
       		
       		//titles.put("giCount", "顾问面试候选人");
       		titles.put("giCount", "顾问面试指标");
       		titles.put("giCountFin", "顾问面试");
       		titles.put("giCountFinRate", "顾问面试完成率");
       		
       		//titles.put("recomCount", "推荐候选人给客户");
       		titles.put("recomCount", "外部推荐指标");
       		titles.put("recomCountFin", "外部推荐");
       		titles.put("recomCountFinRate", "外部推荐完成率");
       		
       		
       		
       		
       		
       		//titles.put("kiCount", "客户面试");
       		titles.put("kiCount", "客户面试指标");
       		titles.put("kiCountFin", "客户面试");
       		titles.put("kiCountFinRate", "客户面试完成率");
       		
       		
       		//titles.put("cvCount", "有效简历输入");
       		
       		titles.put("kpi", "KPI 总分数");
       		HSSFWorkbook wb = ExcelHelper.createExcelWorkbook("员工KPI报表", list, titles);
       		wb.write(os);
       		os.flush();
       		os.close();  
       	}catch(Exception ex){
       		 ex.printStackTrace();
       	}
		
	}
	/**
	 * 员工业绩报表
	 * @param request
	 * @param response
	 * @param reportQuery
	 * @throws IOException
	 */
	public void yjdown(HttpServletRequest request,HttpServletResponse response,ReportQuery reportQuery) throws IOException
	{
		PageRequest<Map> pr = ExtJsPageHelper.createPageRequestForExtJs(request, DEFAULT_SORT_COLUMNS);
		OnlineManager onlineManager=super.getOnlineManager(request, response);
		if (onlineManager!=null){
			OnlineUser onlineUser=onlineManager.getOnlineUser();
			if (onlineUser!=null)reportQuery.setOnlineUser(onlineUser);
			
		}
		//Page page = accountReportService.workKpi(reportQuery);
		
		List list=accountReportService.accountYJSum(reportQuery);
		//
		try{
       		String title=new String(("员工业绩报表.xls").getBytes("GBK"),"iso8859-1"); 
       		//HttpServletResponse response=ServletActionContext.getResponse();
       		response.setHeader("Content-Disposition", "attachment;filename=\""+title+"\"");
       		response.setContentType(CONTENT_EXCEL_TYPE);
       		ServletOutputStream os = response.getOutputStream();
       		Map titles=new LinkedHashMap();
       		//姓名	BD call	BD call完成	客户拜访	客户拜访完成	面试候选人	面试候选人完成	推荐候选人给客户	推荐候选人给客户完成	有效简历输入	有效简历输入完成	KPI 总分数
       		//'account','name','bdCallCount','bdCallCountFin','customerVisitCount','customerVisitCountFin','giCount','giCountFin','recomCount','recomCountFin','cvCount','cvCountFin'
       		titles.put("name", "姓名");
       		titles.put("deptName", "部门");
       		titles.put("statusName", "状态");
       		titles.put("q1t", "Q1指标");
       		titles.put("q1", "Q1实际完成");
       		titles.put("q1r", "Q1完成率");
       		
       		titles.put("q2t", "Q2指标");       		
       		titles.put("q2", "Q2实际完成");
       		titles.put("q2r", "Q2完成率");
       		
       		titles.put("q3t", "Q3指标");
       		titles.put("q3", "Q3实际完成");
       		titles.put("q3r", "Q3完成率");
       		
       		titles.put("q4t", "Q4指标");
       		titles.put("q4", "Q4实际完成");
       		titles.put("q4r", "Q4完成率");
       		
       		titles.put("qat", "年度业绩指标");
       		titles.put("qa", "年度业绩指标完成");
       		titles.put("qar", "年度业绩指标完成率");
       		
       		HSSFWorkbook wb = ExcelHelper.createExcelWorkbook("业绩报表", list, titles);
       		wb.write(os);
       		os.flush();
       		os.close();  
       	}catch(Exception ex){
       		 ex.printStackTrace();
       	}
		
	}
	
	/**
	 * 业绩明细
	 * @param request
	 * @param response
	 * @param reportQuery
	 * @throws IOException
	 */
	public void yjdtldown(HttpServletRequest request,HttpServletResponse response,ReportQuery reportQuery) throws IOException
	{
		PageRequest<Map> pr = ExtJsPageHelper.createPageRequestForExtJs(request, DEFAULT_SORT_COLUMNS);
		OnlineManager onlineManager=super.getOnlineManager(request, response);
		if (onlineManager!=null){
			OnlineUser onlineUser=onlineManager.getOnlineUser();
			if (onlineUser!=null)reportQuery.setOnlineUser(onlineUser);
			
		}
		//Page page = accountReportService.workKpi(reportQuery);
		
		List list=accountReportService.yjmonitor(reportQuery);
		//
		try{
       		String title=new String(("业绩明细.xls").getBytes("GBK"),"iso8859-1"); 
       		//HttpServletResponse response=ServletActionContext.getResponse();
       		response.setHeader("Content-Disposition", "attachment;filename=\""+title+"\"");
       		response.setContentType(CONTENT_EXCEL_TYPE);
       		ServletOutputStream os = response.getOutputStream();
       		Map titles=new LinkedHashMap();
       		titles.put("account", "姓名");
       		titles.put("deptName", "部门");
       		titles.put("ctype", "业绩类型");
       		
       		titles.put("jan", "Jan");
       		titles.put("feb", "Feb");
       		titles.put("mar", "Mar");
       		titles.put("apr", "Apr");
       		
       		titles.put("may", "May");       		
       		titles.put("jun", "Jun");
       		titles.put("jul", "Jul");
       		
       		titles.put("aug", "Aug");
       		titles.put("sep", "Sep");
       		titles.put("oct", "Oct");
       		
       		titles.put("nov", "Nov");
       		titles.put("dec1", "Dec");
       		titles.put("total", "Total");
       		
       		HSSFWorkbook wb = ExcelHelper.createExcelWorkbook("业绩报表", list, titles);
       		wb.write(os);
       		os.flush();
       		os.close();  
       	}catch(Exception ex){
       		 ex.printStackTrace();
       	}
		
	}
	/**
	 * 职位效率分析
	 * @param request
	 * @param response
	 * @param reportQuery
	 * @throws IOException
	 */
	public void jobefflist(HttpServletRequest request,HttpServletResponse response,ReportQuery reportQuery) throws IOException
	{
		//
		PageRequest<Map> pr = ExtJsPageHelper.createPageRequestForExtJs(request, DEFAULT_SORT_COLUMNS);
		OnlineManager onlineManager=super.getOnlineManager(request, response);
		if (onlineManager!=null){
			OnlineUser onlineUser=onlineManager.getOnlineUser();
			if (onlineUser!=null)reportQuery.setOnlineUser(onlineUser);
			
		}
		//Page page = accountReportService.workKpi(reportQuery);
		
		Page page=accountReportService.jobeff(reportQuery);
		
		//List<SystemAuditLog> SystemAuditLoglist = (List) page.getResult();
		ListRange resultList = new ListRange();
		resultList.setRows(page.getResult());
		resultList.setTotal(page.getTotalCount());
		resultList.setMessage("ok");
		resultList.setSuccess(true);
		outJson(response,resultList);
		
	}
	public void jobeffdown(HttpServletRequest request,HttpServletResponse response,ReportQuery reportQuery) throws IOException
	{
		//
		PageRequest<Map> pr = ExtJsPageHelper.createPageRequestForExtJs(request, DEFAULT_SORT_COLUMNS);
		OnlineManager onlineManager=super.getOnlineManager(request, response);
		if (onlineManager!=null){
			OnlineUser onlineUser=onlineManager.getOnlineUser();
			if (onlineUser!=null)reportQuery.setOnlineUser(onlineUser);
			
		}
		//Page page = accountReportService.workKpi(reportQuery);
		
		List list=accountReportService.jobefflist(reportQuery);
		
		try{
       		String title=new String(("职位分析报表.xls").getBytes("GBK"),"iso8859-1"); 
       		//HttpServletResponse response=ServletActionContext.getResponse();
       		response.setHeader("Content-Disposition", "attachment;filename=\""+title+"\"");
       		response.setContentType(CONTENT_EXCEL_TYPE);
       		ServletOutputStream os = response.getOutputStream();
       		Map titles=new LinkedHashMap();
       		//姓名	BD call	BD call完成	客户拜访	客户拜访完成	面试候选人	面试候选人完成	推荐候选人给客户	推荐候选人给客户完成	有效简历输入	有效简历输入完成	KPI 总分数
       		//'account','name','bdCallCount','bdCallCountFin','customerVisitCount','customerVisitCountFin','giCount','giCountFin','recomCount','recomCountFin','cvCount','cvCountFin'

       		
       		titles.put("custName", "客户简称");
       		titles.put("jobName", "职位名称");
       		titles.put("jobStatusName", "职位状态");
       		titles.put("jobManager", "职位负责人");
       		titles.put("deptName", "职位负责人部门");
       		titles.put("createDt", "开始日期");
       		titles.put("ondutyD", "人选上班日期");
       		titles.put("jobdays", "职位周期");
       		titles.put("jdCount", "发JD数");
       		titles.put("recomCount", "推荐数");
       		titles.put("offerCount", "录用数");
       		titles.put("offerrate", "录用比");
       		titles.put("estimateAr", "业绩金额");
       		titles.put("cooperCount", "组成员数");
       		
       		HSSFWorkbook wb = ExcelHelper.createExcelWorkbook("职位分析报表", list, titles);
       		wb.write(os);
       		os.flush();
       		os.close();  
       	}catch(Exception ex){
       		 ex.printStackTrace();
       	}
		
	}
	public void jobmonitorlist(HttpServletRequest request,HttpServletResponse response,ReportQuery reportQuery) throws IOException
	{
		//
		PageRequest<Map> pr = ExtJsPageHelper.createPageRequestForExtJs(request, DEFAULT_SORT_COLUMNS);
		OnlineManager onlineManager=super.getOnlineManager(request, response);
		if (onlineManager!=null){
			OnlineUser onlineUser=onlineManager.getOnlineUser();
			if (onlineUser!=null)reportQuery.setOnlineUser(onlineUser);
			
		}
		//Page page = accountReportService.workKpi(reportQuery);
		
		List list=accountReportService.jobmonitor(reportQuery);
		
		//List<SystemAuditLog> SystemAuditLoglist = (List) page.getResult();
		ListRange<SystemAuditLog> resultList = new ListRange<SystemAuditLog>();
		resultList.setRows(list);
		//resultList.setTotalSize(page.getTotalCount());
		resultList.setMessage("ok");
		resultList.setSuccess(true);
		outJson(response,resultList);
		
	}
	public void jobmonitordown(HttpServletRequest request,HttpServletResponse response,ReportQuery reportQuery) throws IOException
	{
		//
		PageRequest<Map> pr = ExtJsPageHelper.createPageRequestForExtJs(request, DEFAULT_SORT_COLUMNS);
		OnlineManager onlineManager=super.getOnlineManager(request, response);
		if (onlineManager!=null){
			OnlineUser onlineUser=onlineManager.getOnlineUser();
			if (onlineUser!=null)reportQuery.setOnlineUser(onlineUser);
			
		}
		//Page page = accountReportService.workKpi(reportQuery);
		
		List list=accountReportService.jobmonitor(reportQuery);
		
		try{
       		String title=new String(("职位监控.xls").getBytes("GBK"),"iso8859-1"); 
       		//HttpServletResponse response=ServletActionContext.getResponse();
       		response.setHeader("Content-Disposition", "attachment;filename=\""+title+"\"");
       		response.setContentType(CONTENT_EXCEL_TYPE);
       		ServletOutputStream os = response.getOutputStream();
       		Map titles=new LinkedHashMap();
       		//姓名	BD call	BD call完成	客户拜访	客户拜访完成	面试候选人	面试候选人完成	推荐候选人给客户	推荐候选人给客户完成	有效简历输入	有效简历输入完成	KPI 总分数
       		//'account','name','bdCallCount','bdCallCountFin','customerVisitCount','customerVisitCountFin','giCount','giCountFin','recomCount','recomCountFin','cvCount','cvCountFin'
       		
       		
       		titles.put("name", "姓名");
       		titles.put("deptName", "部门");
       		titles.put("jobRole", "职位角色");
       		titles.put("statusName", "状态");
       		titles.put("jobActiveCount", "活跃职位");
       		titles.put("jobNewCount", "新增职位");
       		
       		HSSFWorkbook wb = ExcelHelper.createExcelWorkbook("职位监控", list, titles);
       		wb.write(os);
       		os.flush();
       		os.close();  
       	}catch(Exception ex){
       		 ex.printStackTrace();
       	}
		
	}
	public void jobsumlist(HttpServletRequest request,HttpServletResponse response,ReportQuery reportQuery) throws IOException
	{
		//
		PageRequest<Map> pr = ExtJsPageHelper.createPageRequestForExtJs(request, DEFAULT_SORT_COLUMNS);
		OnlineManager onlineManager=super.getOnlineManager(request, response);
		if (onlineManager!=null){
			OnlineUser onlineUser=onlineManager.getOnlineUser();
			if (onlineUser!=null)reportQuery.setOnlineUser(onlineUser);
			
		}
		//Page page = accountReportService.workKpi(reportQuery);
		
		Page page=accountReportService.jobsum(reportQuery);
		
		//List<SystemAuditLog> SystemAuditLoglist = (List) page.getResult();
		ListRange resultList = new ListRange();
		resultList.setRows(page.getResult());
		resultList.setTotal(page.getTotalCount());
		resultList.setMessage("ok");
		resultList.setSuccess(true);
		outJson(response,resultList);
		
	}
	public void mykpilist(HttpServletRequest request,HttpServletResponse response,ReportQuery reportQuery) throws IOException
	{
		//
		
		PageRequest<Map> pr = ExtJsPageHelper.createPageRequestForExtJs(request, DEFAULT_SORT_COLUMNS);
		OnlineManager onlineManager=super.getOnlineManager(request, response);
		if (onlineManager!=null){
			OnlineUser onlineUser=onlineManager.getOnlineUser();
			if (onlineUser!=null)reportQuery.setAccount(onlineUser.getUsername());
			reportQuery.setOnlineUser(onlineUser);
		}
		//Page page = accountReportService.workKpi(reportQuery);
		System.out.println(reportQuery.getBeginD()+"--"+reportQuery.getEndD());
		List list=accountReportService.workKpi(reportQuery);
		
		//List<SystemAuditLog> SystemAuditLoglist = (List) page.getResult();
		ListRange<SystemAuditLog> resultList = new ListRange<SystemAuditLog>();
		resultList.setRows(list);
		//resultList.setTotalSize(page.getTotalCount());
		resultList.setMessage("ok");
		resultList.setSuccess(true);
		outJson(response,resultList);
		//accountReportService.
	}
	public void bajobsumlist(HttpServletRequest request,HttpServletResponse response,ReportQuery reportQuery) throws IOException
	{
		//
		
		PageRequest<Map> pr = ExtJsPageHelper.createPageRequestForExtJs(request, DEFAULT_SORT_COLUMNS);
		OnlineManager onlineManager=super.getOnlineManager(request, response);
		if (onlineManager!=null){
			OnlineUser onlineUser=onlineManager.getOnlineUser();
			reportQuery.setOnlineUser(onlineUser);
			
		}
        //Page page=accountReportService.bajobsum(reportQuery);
		List list=accountReportService.bajobsum(reportQuery);
		
		//List<SystemAuditLog> SystemAuditLoglist = (List) page.getResult();
		ListRange<SystemAuditLog> resultList = new ListRange<SystemAuditLog>();
		resultList.setRows(list);
		if (list.size()>0)
			resultList.setTotal(list.size()-1);	
		
		resultList.setMessage("ok");
		resultList.setSuccess(true);
		outJson(response,resultList);
		//accountReportService.
	}
	public void bajobsumlistdown(HttpServletRequest request,HttpServletResponse response,ReportQuery reportQuery) throws IOException
	{
		//
		PageRequest<Map> pr = ExtJsPageHelper.createPageRequestForExtJs(request, DEFAULT_SORT_COLUMNS);
		OnlineManager onlineManager=super.getOnlineManager(request, response);
		if (onlineManager!=null){
			OnlineUser onlineUser=onlineManager.getOnlineUser();
			if (onlineUser!=null)reportQuery.setOnlineUser(onlineUser);
			
		}
		//Page page = accountReportService.workKpi(reportQuery);
		
		List list=accountReportService.bajobsum(reportQuery);
		
		try{
       		String title=new String(("BA工作总结.xls").getBytes("GBK"),"iso8859-1"); 
       		//HttpServletResponse response=ServletActionContext.getResponse();
       		response.setHeader("Content-Disposition", "attachment;filename=\""+title+"\"");
       		response.setContentType(CONTENT_EXCEL_TYPE);
       		ServletOutputStream os = response.getOutputStream();
       		Map titles=new LinkedHashMap();
       		//姓名	BD call	BD call完成	客户拜访	客户拜访完成	面试候选人	面试候选人完成	推荐候选人给客户	推荐候选人给客户完成	有效简历输入	有效简历输入完成	KPI 总分数
       		//'account','name','bdCallCount','bdCallCountFin','customerVisitCount','customerVisitCountFin','giCount','giCountFin','recomCount','recomCountFin','cvCount','cvCountFin'
       		
       		//sql2.append(" select a.id,c1.account,c.abbr_name custName,j.parent_ids,m.status,a.name jobName,a.status jobStatus,j.name deptName,l.name titleName,
       		//a.creator,a.job_manager jobManager,a.create_dt createDt,ifnull(f.ccCount,0) ccCount,ifnull(h.cvCount,0) cvCount,ifnull(t3.cvContactCount,0) cvContactCount,ifnull(d.offerCount,0) offerCount,ifnull(d.dutyCount,0) dutyCount,ifnull(e.giCount,0) giCount,ifnull(k.kiCount,0) kiCount,ifnull(i.assistAmount,0) assistAmount  from contract_job a ");
       		titles.put("account", "姓名");
       		titles.put("deptName", "部门");
       		titles.put("titleName", "岗位");
       		titles.put("jobName", "职位名称");
       		titles.put("custName", "客户简称");
       		titles.put("jobManager", "职位负责人");
       		titles.put("ccCount", "新增人选");
       		titles.put("cvCount", "新增简历人选");
       		
       		titles.put("cvContactCount", "新增联系记录");
       		titles.put("recomCount", "内部推荐数");
       		titles.put("giCount", "被顾问面试人选数");
       		titles.put("kiCount", "被客户面试人选数");
       		titles.put("offerCount", "被OFFER人选数");
       		titles.put("dutyCount", "成功上班人选数");
       		titles.put("assistAmount", "辅助成功职位金额");
       		
       		
       		HSSFWorkbook wb = ExcelHelper.createExcelWorkbook("BA工作总结", list, titles);
       		wb.write(os);
       		os.flush();
       		os.close();  
       	}catch(Exception ex){
       		 ex.printStackTrace();
       	}
		
	}
	public void yjmonitorlist(HttpServletRequest request,HttpServletResponse response,ReportQuery reportQuery) throws IOException
	{
		//
		
		PageRequest<Map> pr = ExtJsPageHelper.createPageRequestForExtJs(request, DEFAULT_SORT_COLUMNS);
		OnlineManager onlineManager=super.getOnlineManager(request, response);
		if (onlineManager!=null){
			OnlineUser onlineUser=onlineManager.getOnlineUser();
			reportQuery.setOnlineUser(onlineUser);
			
		}
        List list=accountReportService.yjmonitor(reportQuery);
		
		//List<SystemAuditLog> SystemAuditLoglist = (List) page.getResult();
        ListRange<SystemAuditLog> resultList = new ListRange<SystemAuditLog>();
		resultList.setRows(list);
		//resultList.setTotalSize(page.getTotalCount());
		resultList.setMessage("ok");
		resultList.setSuccess(true);
		outJson(response,resultList);
		//accountReportService.
	}
	public void othertargetlist(HttpServletRequest request,HttpServletResponse response,ReportQuery reportQuery) throws IOException
	{
		//
		
		PageRequest<Map> pr = ExtJsPageHelper.createPageRequestForExtJs(request, DEFAULT_SORT_COLUMNS);
		OnlineManager onlineManager=super.getOnlineManager(request, response);
		if (onlineManager!=null){
			OnlineUser onlineUser=onlineManager.getOnlineUser();
			reportQuery.setOnlineUser(onlineUser);			
		}

		List list=accountReportService.othertarget(reportQuery);
		
		//List<SystemAuditLog> SystemAuditLoglist = (List) page.getResult();
		ListRange<SystemAuditLog> resultList = new ListRange<SystemAuditLog>();
		resultList.setRows(list);
		//resultList.setTotalSize(page.getTotalCount());
		resultList.setMessage("ok");
		resultList.setSuccess(true);
		outJson(response,resultList);
		//accountReportService.
	}
	public void staffEffAnalyselist(HttpServletRequest request,HttpServletResponse response,ReportQuery reportQuery) throws IOException
	{
		//
		
		PageRequest<Map> pr = ExtJsPageHelper.createPageRequestForExtJs(request, DEFAULT_SORT_COLUMNS);
		OnlineManager onlineManager=super.getOnlineManager(request, response);
		if (onlineManager!=null){
			OnlineUser onlineUser=onlineManager.getOnlineUser();
			reportQuery.setOnlineUser(onlineUser);				
		}

		List list=accountReportService.staffEffAnalyse(reportQuery);
		
		//List<SystemAuditLog> SystemAuditLoglist = (List) page.getResult();
		ListRange<SystemAuditLog> resultList = new ListRange<SystemAuditLog>();
		resultList.setRows(list);
		//resultList.setTotalSize(page.getTotalCount());
		resultList.setMessage("ok");
		resultList.setSuccess(true);
		outJson(response,resultList);
		//accountReportService.
	}
	public void customerEffAnalyselist(HttpServletRequest request,HttpServletResponse response,ReportQuery reportQuery) throws IOException
	{
		//
		
		PageRequest<Map> pr = ExtJsPageHelper.createPageRequestForExtJs(request, DEFAULT_SORT_COLUMNS);
		OnlineManager onlineManager=super.getOnlineManager(request, response);
		if (onlineManager!=null){
			OnlineUser onlineUser=onlineManager.getOnlineUser();
			reportQuery.setOnlineUser(onlineUser);
			
		}
        Page page=accountReportService.customerEffAnalyse(reportQuery);
		
		//List<SystemAuditLog> SystemAuditLoglist = (List) page.getResult();
		ListRange resultList = new ListRange();
		resultList.setRows(page.getResult());
		resultList.setTotal(page.getTotalCount());
		resultList.setMessage("ok");
		resultList.setSuccess(true);
		outJson(response,resultList);
		//accountReportService.
	}
	public void staffDataReportlist(HttpServletRequest request,HttpServletResponse response,ReportQuery reportQuery) throws IOException
	{
		//
		
		PageRequest<Map> pr = ExtJsPageHelper.createPageRequestForExtJs(request, DEFAULT_SORT_COLUMNS);
		OnlineManager onlineManager=super.getOnlineManager(request, response);
		if (onlineManager!=null){
			OnlineUser onlineUser=onlineManager.getOnlineUser();
			reportQuery.setOnlineUser(onlineUser);
			
		}
        Page page=accountReportService.staffDataReport(reportQuery);
		
		//List<SystemAuditLog> SystemAuditLoglist = (List) page.getResult();
        System.out.println("page.getTotalCount():"+page.getTotalCount());
		ListRange resultList = new ListRange();
		resultList.setRows(page.getResult());
		resultList.setTotal(page.getTotalCount());
		resultList.setMessage("ok");
		resultList.setSuccess(true);
		outJson(response,resultList);
		//accountReportService.
	}
	public void staffDataReportdown(HttpServletRequest request,HttpServletResponse response,ReportQuery reportQuery) throws IOException
	{
		//
		
		PageRequest<Map> pr = ExtJsPageHelper.createPageRequestForExtJs(request, DEFAULT_SORT_COLUMNS);
		OnlineManager onlineManager=super.getOnlineManager(request, response);
		if (onlineManager!=null){
			OnlineUser onlineUser=onlineManager.getOnlineUser();
			reportQuery.setOnlineUser(onlineUser);
			
		}
        List list=accountReportService.staffDataReportlist(reportQuery);
		
        try{
       		String title=new String(("资料整理报告.xls").getBytes("GBK"),"iso8859-1"); 
       		//HttpServletResponse response=ServletActionContext.getResponse();
       		response.setHeader("Content-Disposition", "attachment;filename=\""+title+"\"");
       		response.setContentType(CONTENT_EXCEL_TYPE);
       		ServletOutputStream os = response.getOutputStream();
       		Map titles=new LinkedHashMap();
       		//姓名	BD call	BD call完成	客户拜访	客户拜访完成	面试候选人	面试候选人完成	推荐候选人给客户	推荐候选人给客户完成	有效简历输入	有效简历输入完成	KPI 总分数
       		//'account','name','bdCallCount','bdCallCountFin','customerVisitCount','customerVisitCountFin','giCount','giCountFin','recomCount','recomCountFin','cvCount','cvCountFin'
       		
       		//员工姓名（允许多选查询）	部门（允许多选查询）	资料类型（人选/公司）允许多选	动作（新增/修改）允许多选	简历/公司完善度（空白，1,2,3……申请删除，SC要求删除）允许多选	数量
       		titles.put("name", "姓名");
       		titles.put("deptName", "部门");
       		titles.put("datatype", "资料类型");
       		titles.put("optype", "动作");
       		titles.put("integrity", "简历/公司完善度");
       		titles.put("cc", "数量");
       		
       		HSSFWorkbook wb = ExcelHelper.createExcelWorkbook("资料整理报告", list, titles);
       		wb.write(os);
       		os.flush();
       		os.close();  
       	}catch(Exception ex){
       		 ex.printStackTrace();
       	}
		//accountReportService.
	}
	
	
	//============
	
	 public String performanceMonitor(HttpServletRequest request, HttpServletResponse response) throws IOException {			
			return "forward:/jsp/report/performanceMonitor.jsp";
     }
	 public String jobMonitor(HttpServletRequest request, HttpServletResponse response) throws IOException {			
			return "forward:/jsp/report/jobMonitor.jsp";
     }
	 public String staffKPI(HttpServletRequest request, HttpServletResponse response) throws IOException {			
			return "forward:/jsp/report/staffKPI.jsp";
     }
	 public String jobSum(HttpServletRequest request, HttpServletResponse response) throws IOException {			
			return "forward:/jsp/report/jobSum.jsp";
     }
	 public String customerBenefitAnalyse(HttpServletRequest request, HttpServletResponse response) throws IOException {			
			return "forward:/jsp/report/customerBenefitAnalyse.jsp";
     }
	 
}
